Skip to content

fix(sdl): expose limit/offset args on paginated list fields (#85)#98

Merged
allmonday merged 1 commit into
masterfrom
fix/85-sdl-pagination-args
Jul 2, 2026
Merged

fix(sdl): expose limit/offset args on paginated list fields (#85)#98
allmonday merged 1 commit into
masterfrom
fix/85-sdl-pagination-args

Conversation

@allmonday

Copy link
Copy Markdown
Collaborator

Summary

  • enable_pagination=True 时,SDL generator 给 paginated list 字段补上 limit / offset args,与 introspection 路径对齐。
  • 字段形态:{field}(limit: Int, offset: Int = 0): {Type}Result!offset 默认值 0 与 introspection 的 defaultValue: "0" 对齐。
  • 复用已有的 _is_paginated_relationship 判定,non-paginated 字段渲染不变。

Why

修复 #85。之前 SDL 和 introspection 对同一个 schema 给出不一致描述:introspection 给 paginated 字段加 limit / offset,SDL 不加。GraphQL 规范要求字段可接受的参数必须在 SDL 里声明——任何走 SDL 而不是 introspection 接 nexusx 的客户端(AI agent / codegen 工具 / GraphiQL 替代品 / 文档生成器)都看不到这些字段能传分页参数,分页功能对它们实际不可达。

Test plan

  • 新增 TestSDLMixedPagination::test_paginated_field_exposes_limit_offset_args,锁 sorted_kids(limit: Int, offset: Int = 0): SortedKidResult!
  • 调整 test_paginated_list_renders_as_result_type:原断言 sorted_kids: SortedKidResult! 因新 args 失效,改为只断言类型后缀
  • TestIntrospectionMixedPagination::test_paginated_field_uses_result_type_with_args 形成对称覆盖
  • tests/test_pagination_mixed.py 8/8 通过
  • 全量回归 1129 passed / 6 skipped / 0 failed

Closes #85.

The SDL generator rendered paginated list fields without args while the
introspection path declared `limit` / `offset` — any client reading the
schema via SDL (codegen tools, AI agents, GraphiQL alternatives) could
not tell these fields were paginated, making the feature unreachable
for them. GraphQL spec requires field args to be declared in SDL.

Reuses `_is_paginated_relationship` to render paginated fields as
`{field}(limit: Int, offset: Int = 0): {Type}Result!`. Offset default
aligns with introspection's `defaultValue: "0"`.

Closes #85.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@allmonday allmonday merged commit 7a94ed4 into master Jul 2, 2026
5 checks passed
allmonday added a commit that referenced this pull request Jul 2, 2026
Version bump for #98 (SDL generator now declares limit/offset args on
paginated list fields, matching the introspection path).
Updates CHANGELOG, pyproject.toml, uv.lock.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDL generator 漏掉 paginated 字段的 limit/offset args(与 introspection 不一致)

1 participant